from django.core.urlresolvers import reverse
from django.utils import feedgenerator
from django.shortcuts import *
from django.template import RequestContext 
from ytbase.helper import *
from ytbase.model.post import *
from ytbase.model.user import *
from ytcommunity.common.helper.context import *

def display(request, id, template):
    user = get_by_str_id(YTUser, id)
    
    filters = []
    filters.append(lambda q: q.filter('author =', user))
    filters.append(lambda q: q.filter('category =', 'FORUM'))
    filters.append(lambda q: q.order('-update'))    
    posts, page = Paginator(request, YTPost, filters).get_page_objects()

    filters = []
    filters.append(lambda q: q.filter('author =', user))
    filters.append(lambda q: q.filter('category =', 'BLOG'))
    filters.append(lambda q: q.order('-date'))    
    blogs, page = Paginator(request, YTPost, filters).get_page_objects()
            
    context = {
        'posts':posts,
        'blogs':blogs,
        'user':user,
    }
    rc = RequestContext(request, processors=PROCESSORS)
    return render_to_response(template, context, rc)

def home(request, template):
    context = {
    }
    rc = RequestContext(request, processors=PROCESSORS)
    return render_to_response(template, context, rc)
